// This company bids for Plumbing only
// Strategy: fixed price


{ include("common.asl") }

!init.
 
+!create_artifacts
   <-  !create_artifact("KITStorageRequest", "artifacts.KITStorageRequestArt", []);
   !create_artifact("WorkMemory", "artifacts.WorkMemoryArt", []);
   !create_artifact("KITCredentials", "artifacts.KITCredentialsArt", []);
   !create_artifact("KITAutentication", "artifacts.KITAutenticationArt", []);
   !create_artifact("kITKnowledgeRequest", "artifacts.KITKnowledgeRequestArt", []);
   !create_artifact("KDAuthentication", "artifacts.KDAuthenticationArt", []);
   !create_artifact("KnowledgeRequest", "artifacts.KnowledgeRequestArt", []);
   !create_artifact("KDCredentials", "artifacts.KDCredentialsArt", []);
   !create_artifact("KnowledgeBase", "artifacts.KwoledgeBaseArt", []);
   !create_artifact("KnowledgeStorage", "artifacts.KwoledgeStorageArt", []);
   !create_artifact("ParserXML", "artifacts.ParserXML", []).
  
+!create_organisational_artifacts
    <- 
    	// Create the group artifact
		makeArtifact("kmGroup","ora4mas.nopl.GroupBoard",["src/integration-os.xml", kmGroup, false, true ],GrArtId);
		adoptRole(knowledge_coordinator_role)[artifact_id(GrArtId)];
		focus(GrArtId);
		
      
		// Create de scheme artifact
		makeArtifact("kmScheme", "ora4mas.nopl.SchemeBoard",["src/integration-os.xml", store_relevant_information_scheme, false, true], SchArtId);
		focus(SchArtId);
		?formationStatus(ok)[artifact_id(GrArtId)]; // see plan belows to ensure we wait until it is well formed
		addScheme("kmScheme")[artifact_id(GrArtId)].
		
+newKnowledgeRequest(ReqID) : ReqID > -1 <-
	lookupArtifact("kITKnowledgeRequest",Id);
	!documentsRetrieving(ReqID);
	!conceptsRetrieving(ReqID);
	!retrievingAditionalRequest(ReqID).

+!documentsRetrieving(ReqID)<-
	//lookupArtifact("kITKnowledgeRequest",Id);
	//focus(Id);
	areThereDocumentRequests(ReqID)[artifact_id(Id)].
	//for (areThereDocumentRequests(ReqID)[artifact_id(Id)]){println("Prueba")}
	
	
+getRequiredDocument(ReqId,Document,Dominio): true <- 
	println(ReqId);
	println(Document);
	println(Dominio).
	
+!documentsRetrieving(ReqID): not areThereDocumentRequests(ReqID) <-
	true.
	
+!conceptsRetrieving(ReqID): true <-
	println(ReqID).
	
+!retrievingAditionalRequest(ReqID): true <-
	println(ReqID).
	
+!init
   <- println;
	  .my_name(Me);
      println("--- Knowledge Coordinator Agent ---");
      println(Me);	  
	  println;
      createWorkspace("integrationWorkspace");
      joinWorkspace("integrationWorkspace",_);
      !create_organisational_artifacts;
      !create_artifacts.
      


      
